<template>
	<view class="sroreLayout pageBg">
		
		
		<nav-bar-two title="仓库预录入" @receiveData="receiveData" @activeIndex="activeIndex"></nav-bar-two>
		<view class="addBtn" @click="addBtn()">新增</view>
			
		<template v-if="filteredData.length">
			<view class="cantainer">
				<scroll-view 
					scroll-y="true" 
					class="scroll-Y"
					refresher-enabled="true"
					:refreshertriggered="triggered"
					@refresherpulling="onPull"
					@refresherrefresh="onRefresh"
					@refresherrestore="onRestore"
					@refresherabort="onAbort"
				>		
					<view class="card-warp" v-for="(row,index) in filteredData" :key="row.lrBill"  @click="editBtn(row)">
						<p>{{row.jybmName}}</p>
						<p>{{row.lrBill}}</p>
						<p>{{row.lrDate}}</p>
						<p>{{row.status}}</p>
					</view>
					
					<view class="safe-area-inset-bottom"></view>
				</scroll-view>
			</view>
		</template>
	
		
		
		<view class="empty-warp" v-else>
			<up-empty
				mode="list"
				icon="http://cdn.uviewui.com/uview/empty/list.png"
			>
			</up-empty>
		</view>

		
	
		
		
	</view>
</template>

<script setup>
// 相当于vue2 的this
const { proxy } = getCurrentInstance();
const swiperList = ref(['/static/images/home/banner.png']);
// 注释代码
let editForm = ref({
	beginTime:'2021-01-01',
	endTime:'2024-12-15',
	lrBill:'',
	comm:'',
})

const tableData = ref([]);
const list = ref(['全部','已审核', '未审核']);  
const active = ref(0);
const triggered = ref(false)


const sectionChange =(index)=>{  
  active.value = index;  
}  

// 接收子组件传来的数据
const receiveData = (data)=>{
	 console.log('接收子组件传来的数据')
	 console.log(data)
	 editForm.value = data
	 console.log(editForm.value)
	 getcangkuList();
}
// 接受子组件传过来的index
const activeIndex = (index)=>{
	 // 接收子组件传来的数据
	 console.log("接受子组件传过来的activeIndex")
	 console.log(index)
	 // 赋值给当前页面的active
	 active.value = index
}
// 调用查询库存事件
const getcangkuList = async ()=>{
	console.log("查询")
	console.log(editForm.value)
	const res = await  proxy.$api.apiCangKu(editForm.value)
	console.log(res)
	tableData.value = res.data
	console.log(tableData.value)
}

// 新增事件
const addBtn = ()=>{
	let id = 13331323192
	uni.navigateTo({
		url:'/pages/store/addStoreOrder?id='+ id,
	})
}

// 修改事件
const editBtn = (row)=>{
	uni.navigateTo({
		url:'/pages/store/addStoreOrder?id='+ JSON.stringify(row),
	})
}
// 定义计算属性
 // 计算属性，根据当前过滤状态返回过滤后的数据
const filteredData = computed(() => {

	 return active.value === 0
					? tableData.value
					: tableData.value.filter(item => (active.value === 1 ? item.status === '1' : item.status !== '1'));
});



const onPull = (()=>{
	console.log('下拉触发');
	triggered.value = true;
})

const onRefresh = (()=>{
	  console.log('正在刷新');
		setTimeout(()=>{
			tableData.value = []
			triggered.value = false
			getcangkuList()
		},2000)
		
})

 const onRestore = (()=>{
	 onsole.log('复位');
 }) 
 
 const onAbort = (()=>{
 	 console.log('取消');
	 triggered.value = false
 })
 
 const queryList = (pageNo, pageSize)=>{
		// console.log(pageNo)
		// console.log(pageSize)
 }


onMounted(() => {
	// 在这里可以执行DOM操作或数据请求
	console.log('组件已挂载');
	getcangkuList()
});

	
</script>

<style lang="scss" scoped>
	
.empty-warp{
	width: 100vw;
	height: 100vh;
}


/* 微信小程序平台样式 */
/* #ifdef MP-WEIXIN */
.cantainer{
	height:calc(100vh - 128px);  //+44
}
/* #endif */


/* H5 平台样式 */
/* #ifdef H5 */
.cantainer{
	height:calc(100vh - 74px);  //+44
}
/* #endif */
.cantainer{
	width: 100%;
	box-sizing: border-box;
}

.scroll-Y{
	width: 100%;
	height: 100%;
	box-sizing: border-box;
	padding: 10px 10px 0px 10px;
}


.card-warp {
	box-sizing: border-box;
	margin-bottom: 20px; /* 修改外边距为20px */
	padding: 20rpx;
	background-color: #fff;
	border: 1px solid #f4f4f4;
	border-radius: 15px;
}

.addBtn{
	width: 100rpx;
	height: 100rpx;
	background-color: $brand-theme-color;
	color: #fff;
	position: fixed;
	bottom: 150rpx;
	right:30rpx;
	z-index: 999;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 28rpx;
}
</style>
